<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
    <head>
        <meta charset="UTF-8">
        <title>用户管理页面</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="../../static/css/font.css">
        <link rel="stylesheet" href="../../static/css/xadmin.css">
        <script src="../../static/lib/layui/layui.js" charset="utf-8"></script>
        <script src="../../static/js/xadmin.js"></script>
        <!--[if lt IE 9]>
          <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
          <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
    </head>
    <body>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header">
                            <button class="layui-btn" onclick="xadmin.open('添加用户','/addIndex',800,600)"><i class="layui-icon"></i>添加</button>
                        </div>
<!--                        <div class="layui-card-header">-->
                            <!--<input id="file" class="layui-icon" type="file" name="file">-->
<!--                            <button class="layui-btn"  id="importExcel">导入值班表</button>-->
<!--                        </div>-->
                        <!--<form action="/importDuty" enctype="multipart/form-data" method="post">
                            <input class="layui-icon" type="file" name="file">
                            <input class="layui-btn" type="submit">
                        </form>-->
                        <div class="layui-card-body ">
                            <table class="layui-table layui-form">
                              <thead>
                                <tr>
                                  <!--<th>
                                    <input type="checkbox" name=""  lay-skin="primary">
                                  </th>-->
                                   <th>登录名</th>
                                   <th>名称</th>
                                    <th>备注</th>
                                    <th>状态</th>
                                    <th>操作</th>
                              </thead>
                              <tbody>
                                <tr th:each="user:${users}">
                                  <input type="hidden" th:value="${user.id}">
                                  <td th:text="${user.userName}"></td>
                                  <td th:text="${user.account}"></td>
                                    <td th:text="${user.remark}"></td>
                                  <td class="td-status" th:switch="${user.dataStatus}">
                                      <span class="layui-btn layui-btn-normal layui-btn-mini" th:case="0">
                                          <p >已启用</p>
                                      </span>
                                      <span class="layui-btn layui-btn-danger layui-btn-mini" th:case="1">
                                          <p >已停用</p>
                                      </span>
                                  </td>
                                    <!--<span class="layui-btn layui-btn-normal layui-btn-mini">已启用</span>-->
                                  <td class="td-manage">
                                    <a  th:href="@{/deleteUser(id=${user.id})}" >
                                      <i class="layui-icon">&#xe601;</i>
                                    </a>
                                    <a  th:href="@{/updateAllIndex(id=${user.id})}" >
                                      <i class="layui-icon">&#xe642;</i>
                                    </a>
                                    <!--<a title="删除" onclick="member_del(this,'要删除的id')" href="javascript:;">
                                      <i class="layui-icon">&#xe640;</i>
                                    </a>-->
                                  </td>
                                </tr>
                              </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div> 
    </body>
    <script th:inline="none">
        layui.use([ 'layer', 'table','upload'], function(){
            var upload = layui.upload;
            var uploadInst = upload.render({
                elem: '#importExcel' //绑定元素
                ,url:'/importDuty'
                ,accept:'file'
                ,exts: 'xlsx'

                ,done: function(res, index, upload) {
                    alert("值班表导入成功");

                }
                ,error: function(){
                    //请求异常回调
                    layui.msg("异常");
                }
            });
        })
        var update = function (title,url,id,full) {
                var laydate = layui.layer;
                var index = laydate.open({
                    type: 2,
                    area: [w + 'px', h + 'px'],
                    fix: false, //不固定
                    maxmin: true,
                    shadeClose: true,
                    shade: 0.4,
                    title: title,
                    content: '/updateIndex'
                });
                if (full) {
                    layer.full(index);
                }
        }
       /*用户-停用*/
     /* function member_stop(obj,id){
          layer.confirm('确认要改变吗？',function(index){

              if($(obj).attr('title')=='启用'){

                //发异步把用户状态进行更改
                $(obj).attr('title','停用')
                $(obj).find('i').html('&#xe62f;');

                $(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已停用');
                layer.msg('已停用!',{icon: 5,time:1000});

              }else{
                $(obj).attr('title','启用')
                $(obj).find('i').html('&#xe601;');

                $(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已启用');
                layer.msg('已启用!',{icon: 5,time:1000});
              }
              layer.open({
                  type:2,
                  content:'http://www.baidu.com'
              })
          });
      }*/

      /*用户-删除*/
      function member_del(obj,id){
          layer.confirm('确认要删除吗？',function(index){
              //发异步删除数据
              $(obj).parents("tr").remove();
              layer.msg('已删除!',{icon:1,time:1000});
          });
      }



      function delAll (argument) {

        var data = tableCheck.getData();
  
        layer.confirm('确认要删除吗？'+data,function(index){
            //捉到所有被选中的，发异步进行删除
            layer.msg('删除成功', {icon: 1});
            $(".layui-form-checked").not('.header').parents('tr').remove();
        });
      }
    </script>
    <script>var _hmt = _hmt || []; (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();</script>
</html>